<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>event-test</title>
    <!-- 生产环境版本，优化了尺寸和速度 -->
    <script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
</head>
<body>
<div id="example">
    <!-- `greet` 是在下面定义的方法名 -->
    {{name}}
    <button v-on:click="greet">Greet</button>
</div>

<div id="example-2">
    <input v-model=sayMsg>
    <!--    绑定变量到输入框，-->
    <button v-on:click="say(sayMsg,$event)">Say hi</button>
    <button v-on:click="say('what',$event)">Say what</button>

</div>
<script>
    new Vue({
        el: '#example-2',
        data: {
            name: "vue.js",
            sayMsg: ''
        },
        methods: {
            greet: function (event) {
                console.log(event)
            },
            say: function (msg, event) {
                console.log(msg + "  " + event)

            }
        }
    })
</script>
</body>
</html>